#include "MainView.h"
#include <ncurses.h>
#include "../Model/Model.h"
#include "../Model/Library.h"


MainView::MainView(int col,int row) : 
	col(col), row(row) {}

MainView::void View::doMainCycle() {
	
	while (!exit) {
		int ch = getch();
		switch (ch) {

			case KEY_UP:
				if (first_line_shown > 0) {
					--first_line_shown;
				}
				show();
				break;
			case KEY_DOWN:
				if (first_line_shown <= model.getBookSize() - 2) {
					++first_line_shown;
				}
				show();
				break;
			case V_EXIT_KEY:
				exit = TRUE;
				break;
			case V_SWITCH_KEY:
				if (col > oldCol) {
					col -= V_COL_CORRECT;
				} else {
					col += V_COL_CORRECT;
				}
				model.setLinesRed(first_line_shown);
				model.switchSource();
				first_line_shown = model.getLinesRed();
				show();
				break;
			case V_SWITCH_MENU_KEY:
				showSwitchMenu();
				show();
				break;
			case V_PM_START:
				am.play();
				playMode();
				show();
				break;

		}
		
	}
}
 
